package com.mobibom.pipelines;

import pipelines.free.beta.R;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class LevelPackActivity extends Activity {
     Button westernButton, alienButton, beerButton;
	 private AdView adView1;
	 private static final String MY_BANNER_UNIT_ID = "a14ed7bde839b79";
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.levelpackview);
	   
	    setUpView(); 
	    addOnClickListeners();
	}
	private void setUpView() {
		westernButton = 	(Button)findViewById(R.id.buttonWestern);
		alienButton = 		(Button)findViewById(R.id.buttonAlien);
		beerButton =		(Button)findViewById(R.id.buttonBeer);
		
		// Lookup R.layout.main
        LinearLayout layout = (LinearLayout)findViewById(R.id.layoutAdsLevelPack);
        // Create the adView
        // Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
        adView1 = new AdView(this, AdSize.BANNER, MY_BANNER_UNIT_ID);
        // Add the adView to it
        layout.addView(adView1);
        // Initiate a generic request to load it with an ad
        AdRequest request = new AdRequest();
        //request.setTesting(true);
        adView1.loadAd(request);       
	}

	private void addOnClickListeners() {
		 westernButton.setOnClickListener(new View.OnClickListener(){@Override public void onClick(View v) {openLevelPack(1);}});
		 alienButton.setOnClickListener(new View.OnClickListener(){@Override public void onClick(View v) {openLevelPack(2);}});
		 beerButton.setOnClickListener(new View.OnClickListener(){@Override public void onClick(View v) {openLevelPack(3);}});
	}
	private void openLevelPack(int i){
		//open level
		Intent levelpack = new Intent(getApplicationContext(), ChooseLevelActivity.class);
		levelpack.putExtra("levelpack", i);
		startActivity(levelpack);
	}
	
}
